﻿using Basic.FlowGatewayModule.Interface;
using Basic.FlowGatewayModule.Model;
using Basic.FlowRemoteModel.NodeFormData.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;

namespace Basic.FlowGatewayModule.Api
{
    [ApiRouteName("/flow/node/form/relation/{name}")]
    internal class NodeFormDataRelationApi : ApiController
    {
        private readonly INodeFormDataRelationService _Service;

        public NodeFormDataRelationApi ( INodeFormDataRelationService service )
        {
            this._Service = service;
        }

        public DataRelation[] Gets ( [NumValidate("flow.node.id.error", 1)] long nodeId )
        {
            return this._Service.Gets(nodeId);
        }

        public void Sync ( SetDataRelation set )
        {
            this._Service.Sync(set.FlowId, set.NodeId, set.Relations);
        }
    }
}
